package com.csusm.geo.science.tutor;

import org.json.JSONException;
import org.json.JSONObject;

public class ActivityDbHelper {
	public Match getLinks(String selLoc) {
		String url = "http://ouyangdev.cs.csusm.edu/GeoTutor/getactivity.php";
		//Get the data from database
		String result = UtilityHelper.getResult(selLoc, url);
		// paring data
		String qid = null;
		String matcha = null;
		String matchb = null;
		String answer = null;
		try {
			
			JSONObject json = new JSONObject(result);
			qid = json.getString("eid");
			matcha = json.getString("matcha");
			matchb = json.getString("matchb");
			answer = json.getString("answer");
		} catch (JSONException e1) {
			e1.printStackTrace();
		}
		//Set the Match object
		Match match = new Match();
		match.setEid(qid);
		match.setMatcha(matcha);
		match.setMatchb(matchb);
		match.setAnswer(answer);
		return match;
	}	
}
